﻿using L5_Event.Event;
using Prism.Commands;
using Prism.Dialogs;
using Prism.Events;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace L5_Event.ViewModels
{
    public class DialogViewModel : BindableBase, IDialogAware
    {
        private readonly IEventAggregator eventAggregator;

        public DialogCloseListener RequestClose { get; }

        #region 记录
        public DelegateCommand RecordCommand { get; set; }
        void ExcuteRecord()
        {
            eventAggregator.GetEvent<LogEvent>().Publish($"[{DateTime.Now}] DialogView Record");
        }
        #endregion

        public DialogViewModel(IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator;

            RecordCommand = new DelegateCommand(ExcuteRecord);
        }

        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {
        }

        public void OnDialogOpened(IDialogParameters parameters)
        {
        }
    }
}